package com.mdd.admin.controller.yylq;

import com.mdd.admin.aop.Log;
import com.mdd.admin.service.yylq.ITAppStoreService;
import com.mdd.admin.validate.commons.IdValidate;
import com.mdd.admin.validate.commons.PageValidate;
import com.mdd.admin.validate.yylq.TAppStoreCreateValidate;
import com.mdd.admin.validate.yylq.TAppStoreSearchValidate;
import com.mdd.admin.validate.yylq.TAppStoreUpdateValidate;
import com.mdd.admin.vo.yylq.TAppStoreDetailVo;
import com.mdd.admin.vo.yylq.TAppStoreListedVo;
import com.mdd.common.core.AjaxResult;
import com.mdd.common.core.PageResult;
import com.mdd.common.entity.yangyangLeadingEnterprise.common.JsonReturn;
import com.mdd.common.validator.annotation.IDMust;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.annotation.Resource;

@RestController
@RequestMapping("/adminapi/yylq/store")
@Api(tags = "羊羊领企---门店管理")
public class TAppStoreController {

    @Resource
    ITAppStoreService iTAppStoreService;

    @GetMapping("/list")
    @ApiOperation(value="门店列表")
    public AjaxResult<PageResult<TAppStoreListedVo>> list(@Validated PageValidate pageValidate,
                                                          @Validated TAppStoreSearchValidate searchValidate) {
        PageResult<TAppStoreListedVo> list = iTAppStoreService.list(pageValidate, searchValidate);
        return AjaxResult.success(list);
    }

    @GetMapping("/detail")
    @ApiOperation(value="门店详情")
    public AjaxResult<TAppStoreDetailVo> detail(@Validated @IDMust() @RequestParam("id") Integer id) {
        TAppStoreDetailVo detail = iTAppStoreService.detail(id);
        return AjaxResult.success(detail);
    }

    @Log(title = "门店新增")
    @PostMapping("/add")
    @ApiOperation(value="门店新增")
    public AjaxResult<Object> add(@Validated @RequestBody TAppStoreCreateValidate createValidate) {
        iTAppStoreService.add(createValidate);
        return AjaxResult.success();
    }

    @Log(title = "门店编辑")
    @PostMapping("/edit")
    @ApiOperation(value="门店编辑")
    public AjaxResult<Object> edit(@Validated @RequestBody TAppStoreUpdateValidate updateValidate) {
        iTAppStoreService.edit(updateValidate);
        return AjaxResult.success();
    }

    @Log(title = "门店删除")
    @PostMapping("/del")
    @ApiOperation(value="门店删除")
    public AjaxResult<Object> del(@Validated @RequestBody IdValidate idValidate) {
        iTAppStoreService.del(idValidate.getId());
        return AjaxResult.success();
    }



}
